#!/usr/bin/env python
# vim: set fileencoding=UTF-8

###############################################################################
#
# filename:  wingide.py
#
# purpose:   Preinstall for wingide config section
#
# author(s): Alessandro Molari (mola89.molarulez.com)
#            Luca Molari
#
# license:   This file is licensed under the GPLv2
#            For more informations read:
#            http://www.gnu.org/licenses/gpl-2.0.txt
#
# part of:   This file is part of the XazeInstaller
#
###############################################################################



import os
import management.utils



def main(main_space, startdir, currentuser):
    # create the 'FileInfo' object
    fileinfo = management.utils.FileInfo(currentuser)

    # set 'cu_dir' as the home directory for the current user
    cu_dir = fileinfo.get_currentuserhome()

    # 'vimdir' creation and setup
    vimdir = os.path.abspath(os.path.join(cu_dir, ".wingide3"))
    if not os.path.isdir(vimdir):
        os.mkdir(vimdir)
        print "%s>>> Created dir %s" % (main_space, vimdir)
        
        # change owner of 'vimdir' to the current user
        fileinfo.setup_owner(main_space, vimdir, lambda: "#USER#")
        # change group of 'vimdir' to the current group
        fileinfo.setup_group(main_space, vimdir, lambda: "#USERS#")

